using System;
using Voodoo.GameOps;
using Voodoo.Pattern;

public class UpgradesContainer : BaseContainer<UpgradesContainer>
{
	public Item DroneItem;

	public override void Fill()
	{
		SingletonMB<ShopButtonGroup>.Instance.UpgradesButton.SwitchNotification(itemAvailable: false);
		content.gameObject.SetActive(value: true);
		backBtn.gameObject.SetActive(value: true);
		for (int i = 0; i < buyButtons.Count; i++)
		{
			buyButtons[i].Fill(DisplayItems[i]);
			BuyButton buyButton = buttonPrefab;
			buyButton.OnClicked = (Action)Delegate.Combine(buyButton.OnClicked, new Action(OnClicked));
			if (InventoryManager.Instance.HasInventory(DisplayItems[i]) && InventoryManager.Instance.CurrentBalance() >= (float)InventoryManager.Instance.GetPrice(DisplayItems[i]))
			{
				SingletonMB<ShopButtonGroup>.Instance.UpgradesButton.SwitchNotification(itemAvailable: true);
			}
		}
		Hide();
	}

	public override void OnClicked()
	{
		base.OnClicked();
		for (int i = 0; i < buyButtons.Count && i < DisplayItems.Count; i++)
		{
			if (!(DisplayItems[i].ID == "MULTIPLESAWS") || Preloader.ShopConfig.MultipleSaw)
			{
				buyButtons[i].Fill(DisplayItems[i], useCurrency: true, showLevel: true);
			}
		}
		if (Preloader.ShopConfig.DrillingDrone)
		{
			buyButtons[buyButtons.Count - 1].Fill(DroneItem, useCurrency: true, showLevel: true);
			Item item = InventoryManager.Instance.CurrentlySelected(ItemType.Skin);
			if ((bool)item && (bool)item.DroneIcon)
			{
				buyButtons[buyButtons.Count - 1].icon.sprite = item.DroneIcon;
			}
		}
		SingletonMB<GameManager>.Instance.currentOilUI.UpdateValues();
	}

	public override void Refresh()
	{
		SingletonMB<ShopButtonGroup>.Instance.UpgradesButton.SwitchNotification(itemAvailable: false);
		for (int i = 0; i < buyButtons.Count && i < DisplayItems.Count; i++)
		{
			if (!(DisplayItems[i].ID == "MULTIPLESAWS") || Preloader.ShopConfig.MultipleSaw)
			{
				buyButtons[i].Fill(DisplayItems[i], useCurrency: true, showLevel: true);
				Item item = DisplayItems[i];
				if (InventoryManager.Instance.HasInventory(item) && InventoryManager.Instance.CurrentBalance() >= (float)InventoryManager.Instance.GetPrice(item))
				{
					SingletonMB<ShopButtonGroup>.Instance.UpgradesButton.SwitchNotification(itemAvailable: true);
				}
			}
		}
		if (Preloader.ShopConfig.DrillingDrone)
		{
			buyButtons[buyButtons.Count - 1].Fill(DroneItem, useCurrency: true, showLevel: true);
			Item item2 = InventoryManager.Instance.CurrentlySelected(ItemType.Skin);
			if ((bool)item2 && (bool)item2.DroneIcon)
			{
				buyButtons[buyButtons.Count - 1].icon.sprite = item2.DroneIcon;
			}
			Item droneItem = DroneItem;
			if (InventoryManager.Instance.HasInventory(droneItem) && InventoryManager.Instance.CurrentBalance() >= (float)InventoryManager.Instance.GetPrice(droneItem))
			{
				SingletonMB<ShopButtonGroup>.Instance.UpgradesButton.SwitchNotification(itemAvailable: true);
			}
		}
		base.Refresh();
	}

	private void Start()
	{
		SingletonMB<UpgradesContainer>.Instance.Fill();
		foreach (BuyButton buyButton in buyButtons)
		{
			buyButton.HideActiveIcon();
		}
		buyButtons[base.ActiveBtn].ShowActiveIcon();
	}
}
